import renderTemplate from './template'
import { Selector } from './config'
import { defaultConfig } from './config'
import { getAttributes } from '../../shared'
export default class SenButton extends HTMLElement {
    public rootFontSize
    public config = defaultConfig
    constructor() {
        super()
        this.render()
        this.rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
    }
    // 生命周期
    connectedCallback() {
    }
    attributeChangedCallback(name: string, oldValue: any, newValue: any) {
        console.log(name, 'name', oldValue, 'oldValue', newValue, 'newValue')
    }
    // 挂载监听事件
    mountEventListener() {

    }
    // 渲染dom
    render() {
        this.config = { ...getAttributes(this), ...this.config }
        const shadowRoot = this.attachShadow({ mode: 'open' });
        shadowRoot.innerHTML = renderTemplate(this.config)
    }
}
if (!customElements.get(Selector)) {
    customElements.define(Selector, SenButton)
}